package com.axxc.jpa.entity;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import com.axxc.jpa.out.Developer;
/**
 * 		
 * @ClassName: EnumUserEntity 
 * @Description: jpa 实现枚举映射
 * @author xxc
 * @date 2018年8月10日 下午12:00:34
 * @see 参考自 	https://www.cnblogs.com/luyang
 * @see 自定义枚举实现参考 	https://www.cnblogs.com/xiaoq/p/7885775.html
 */
@Entity
@Table(name = "enum_user")
public class EnumUserEntity extends Developer{
	private static final long serialVersionUID = 1L;

	/**
	 * 用户类型
	 */
	public static enum AccountType {
		TEACHER, // 老师
		STUDENT;// 学生
	}

	@Id
	@GeneratedValue
	private Long id;

	private String name;

	private int age;


    /**
     * EnumType:  ORDINAL 枚举序数  默认选项（int）。eg:TEACHER 数据库存储的是 0
     *            STRING：枚举名称       (String)。eg:TEACHER 数据库存储的是 "TEACHER"
     */
	
	@Enumerated(EnumType.STRING)
	private AccountType accountType = AccountType.TEACHER;
	/**
	 * 此两种方法都可实现枚举类型,并且修改数据库类型为enum  也可插入数据成功,实现了枚举"下拉选择"
	 */
	@Enumerated(EnumType.STRING)
	private Enum<AccountType> type;
	
	public Enum<AccountType> getType() {
		return type;
	}

	public void setType(Enum<AccountType> type) {
		this.type = type;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public EnumUserEntity() {
		super();
	}

	public AccountType getAccountType() {
		return accountType;
	}

	public void setAccountType(AccountType accountType) {
		this.accountType = accountType;
	}
	
}